package jalus.service;

import jalus.dao.AccessLogDAO;
import jalus.model.AccessLog;
import jalus.utils.MyUtils;

import java.util.Date;
import java.util.List;

public class AccessLogService {
	private static AccessLogService instance = new AccessLogService();
	private AccessLogDAO accessLogDAO;
	private AccessLogService(){
		accessLogDAO = new AccessLogDAO();
	}
	public static AccessLogService getInstance(){
		return instance;
	}
	
	public List<AccessLog> getAccessLogList(){
		return accessLogDAO.getAllAccessLog();
	}
	
	public void addAccessLog(AccessLog accessLog){
		accessLogDAO.addAccessLog(accessLog);
	}
	/**
	 * 获取date当天的访问量
	 * @param date
	 * @return
	 */
	public List<AccessLog> getAccessLogListByDate(Date date) {
		Date beginDate = MyUtils.getDayBeginDateCCT(date);
		Date endDate = MyUtils.getDayEndDateCCT(date);
		return accessLogDAO.getAccesslogByDate(beginDate, endDate);
	}
}
